import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { ReactiveFormsModule, FormsModule } from '@angular/forms';
import { RouterModule, Routes } from '@angular/router';

import { AdminDashboardComponent } from './components/admin-dashboard/admin-dashboard.component';
import { ProblemFormComponent } from './components/problem-form/problem-form.component';
import { BatchImportComponent } from './components/batch-import/batch-import.component';
import { AdminGuard } from './guards/admin.guard';

const routes: Routes = [
  {
    path: '',
    component: AdminDashboardComponent,
    canActivate: [AdminGuard]
  },
  {
    path: 'problems/create',
    component: ProblemFormComponent,
    canActivate: [AdminGuard]
  },
  {
    path: 'problems/edit/:id',
    component: ProblemFormComponent,
    canActivate: [AdminGuard]
  },
  {
    path: 'problems/batch-import',
    component: BatchImportComponent,
    canActivate: [AdminGuard]
  }
];

@NgModule({
  declarations: [
    AdminDashboardComponent,
    ProblemFormComponent,
    BatchImportComponent
  ],
  imports: [
    CommonModule,
    ReactiveFormsModule,
    FormsModule,
    RouterModule.forChild(routes)
  ]
})
export class AdminModule { } 